package com.rxmvp.rxmvpdemo.RxBus;

import android.support.annotation.IntDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 *  RxBus的所有事件在这里定义
 *     EventCode对应 -> content内容(可能为null)
 *
 * 作者： huangRZ on 2017/1/21. 15:04
 * 邮箱：917647409@qq.com
 */
public class Events<T> {

    //所有事件的CODE
    public static final int TAP = 1; //点击事件
    public static final int OTHER = 21; //其它事件
    public static final int LOAD_IMAGE = 31;


    //枚举
    @IntDef({TAP, OTHER, LOAD_IMAGE})
    @Retention(RetentionPolicy.SOURCE)
    public @interface EventCode {}


    private @Events.EventCode int code;
    private T content;

    @EventCode
    public int getCode() {
        return code;
    }

    public void setCode(@Events.EventCode int code) {
        this.code = code;
    }

    public static <O> Events<O> creatEvents(O t) {
        Events<O> events = new Events<>();
        events.content = t;
        return events;
    }

    public void setContent(T content) {
        this.content = content;
    }

    public T getContent() {
        return content;
    }

}
